package com.example.springbootv1.controller;

import com.example.springbootv1.pojo.Employee;
import com.example.springbootv1.pojo.Position;
import com.example.springbootv1.service.PositionAndEmployeeService;
import com.example.springbootv1.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/positionAndEmployee")
@CrossOrigin(origins = "*")
public class PositionAndEmployeeController {
    @Autowired
    private PositionAndEmployeeService positionAndEmployeeService;

    @PostMapping("/postEmployeeByPosition")
    public Result getPositionList(@RequestBody Position position) {

        return Result.success(positionAndEmployeeService.getEmployeeByPosition(position));
    }

    @PostMapping("postPositionByEmployee")
    public Result getEmployeeList(@RequestBody Employee employee) {
        return Result.success(positionAndEmployeeService.getPositionByEmployee(employee));
    }
}
